<template>
  <div class="page page-role">
    <c-content
            :page.sync="pages.page"
            :limit.sync="pages.limit"
            :totalRow.sync="pages.totalRow"
            @pagination="pageChange">
      <!-- 查询 -->
      <el-form slot="search" :inline="true" class="search-form" label-width="100px" @submit.native.prevent>
       <!-- <el-form-item class="search-btn">
          <el-button v-waves type="primary" @click="openXM" size="mini">新增</el-button>
        </el-form-item>-->
        <el-form-item label="检测特征名称">
          <el-input v-model="form.name" placeholder="请输入检测特征名称" clearable @keyup.enter.native="getList()" @clear="getList()" />
        </el-form-item>
      </el-form>
      <!-- 展示 -->
      <el-table
          slot="table"
          ref="multipleTable"
          v-loading="tab_loading"
          width="100%"
          border
          :data="dataList"
          class="expand--table">
        <el-table-column align="center" prop="featureName" label="被测参数名称" />
        <!-- <el-table-column align="center" prop="featureId" label="顺序的被测参数号" /> -->
        <!-- <el-table-column align="center" prop="partId" label="顺序的零件号" /> -->
        <el-table-column align="center" prop="k2110" label="上限" />
        <el-table-column align="center" prop="k2111" label="下限" />
        <el-table-column align="center" prop="k2101" label="名义值" />
        <el-table-column align="center" prop="k2142" label="单位" />
        <!--<el-table-column align="center" label="操作">
          <template slot-scope="scope">
            <c-button>
              <span @click="openXM(scope.row)">编辑</span>
              <span @click="handleDel(scope.row)" class="danger">删除</span>
            </c-button>
          </template>
        </el-table-column>-->
      </el-table>


    </c-content>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { getFeatures } from '@/api/xapi'
import AddEdit from './XM/AddEditDetect'
export default {
  components: {
    CContent: () => import('@/components/CContent'),
    // CButton: () => import('@/components/CButton')
  },
  computed: {
    ...mapGetters(['btn_permission'])
  },
  props: {
    layerid: {
      default: 0
    }
  },
  data() {
    return {
      tab_loading: false,
      pages: this.$mpages,
      form: {},
      dataList: []
    }
  },
  created() {
    this.$getReset();
     this.getList();
  },
  methods: {
    /* 查询 */
    async getList() {
      const obj = JSON.parse(JSON.stringify(this.form))
        Object.assign(obj, this.pages)
      this.tab_loading = true
      const { data } = await getFeatures(obj)
      this.tab_loading = false
      this.dataList = data.data
      this.pages.totalRow = data.totalRow
    },
    /* 删除 */
    // handleDel(row) {
    //   this.$confirm('确认删除此信息?', '提示', {
    //     confirmButtonText: '确认',
    //     cancelButtonText: '取消',
    //     type: 'warning'
    //   }).then(async () => {
    //     const res = await deleteFeatures(row.id)
    //    if (res.status == 200) {
    //       this.$message({ message: '删除成功', type: 'success' })
    //       this.getList()
    //    }
    //   }).catch(() => {
    //   })
    // },
    /* 添加和编辑 */
    openXM(row) {
      this.$layer.iframe({
        shadeClose:false,
        content: {
          content: AddEdit,
          parent: this,
          data: { row: row }
        },
        maxmin: true,
        area: ['600px', '500px'],
        title: row.id ? '编辑检测特征' : '添加检测特征'
      })
    },
      /* 页码改变 */
      pageChange(param) {
          if (param.type === 'index') this.pages.page = param.val
          if (param.type === 'sizes') this.pages.pagesize = param.val
          this.getList()
      }
  }
}
</script>

<style lang="scss" scoped>

</style>

